package ComputerUsb;

public interface USB{
    void turnOn;
    void turnOff;
}

public class Mouse implements USB{
    public void turnOn(){
        System.out.println("the mouse is turning on!");
    }
    public void turnOff(){
        System.out.println("the mouse is turning off!");
    } 
}

public class KeyBoard implements USB{
    public void turnOn(){
        System.out.println("the keyboard is turning on!");
    }
    public void turnOff(){
        System.out.println("the keyboard is turning off!");
    } 
}


public class Mic implements USB{
    public void turnOn(){
        System.out.println("the mic is turning on!");
    }
    public void turnOff(){
        System.out.println("the mic is turning off!");
    } 
}

public class Computer{
    private USB[] usbArr = new USB[4];
    public void add(USB usb){
        for (int i = 0;i<usbArr.length;i++){
            if (usbArr[i]==null){
                usbArr[i] = usb;
                break;
            }
        }
    }
}

public  void powerOn(){
    for (int i = 0;i<usbArr.length;i++){
        if (usbArr[i] != null){
            usbArr[i].turnOn(); 
        }
    }
    System.out.println("the computer is working now!");
}


public void powerOff(){
    for (int i = 0;i<usbArr.length;i++){
        if (usbArr[i] != null){
            usbArr[i].turnOff(); 
        }
    }
    System.out.println("the computer is sleeping now!");
}
